<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>冒泡排序</title>
	</head>
	<body>
		<script>
			var arr=[98,31,5,27,2,78];
			console.log("待排序数组"+arr);
			for(var i=1;i<=arr.length;i++){
				for(j=0;j<=arr.length-i;j++){
					if(arr[j]>arr[j+1]){
						var temp=arr[j];
						arr[j]=arr[j+1];
						arr[j+1]=temp;
					}
				}
			}
			console.log("排序后的数组"+arr);
		</script>
	</body>
</html>
